<template>
  <div class="home">
    <p ref="pcon">p元素</p>
    <ChildView ref="childview" />
  </div>
</template>

<!-- setup新写法 -->
<script setup>
import { ref, onMounted } from 'vue';
import ChildView from '@/components/ChildView.vue'
// 当前ref变量,获取对应名称的DOm元素
let pcon = ref(null);
let childview = ref(null);

// console.log(this.$ref);

// 生命周期挂载后
onMounted(() => {
  console.log(pcon.value.innerText);
  console.log(childview.value.msg);
})

</script>
